require ['knockout','jquery','bootstrap'], (ko, $) ->
  class viewModel
    constructor: ->
    success: ->
      alert '删除成功！'
    seatherText: ko.observable ''
    clickDetete: ->
      idsArrey = new Array()
      for i in $('#center_list tr')
        p = $(i).attr('ids')
        if !isNaN(Number(p)) && !!p && $(i).find('.checkBox').hasClass('on')
          idsArrey.push(p)
      ids = idsArrey.join(",")
      if !!ids
        Promise.resolve $.ajax
          type: 'post'
          url: './companypostDelbyids'
          data:
            'ids':ids
        .then (data)=>
          console.log data
          @success()
      return
    clickSeather: ()->
      console.log @seatherText()
      window.location.href = '?seacherText='+@seatherText()
  ko.applyBindings new viewModel()
  $ ->
    class checkBoxState
      state:false
      getState: (d,name,n) ->
        @forState(d,name,n)
        @state
      forState: (d,name,n)->
        i = 0
        while i<d.length
          if $(d[i]).hasClass(name)
            @state = n
            break
          else
            @state = !n
          i++
        return
    cbs = new checkBoxState()
    $('#allselectCtrl').click ->
      if !cbs.getState($('.checkBox'),'off',false)
        $('.checkBox').removeClass('off')
        $('.checkBox').addClass('on')
      else
        $('.checkBox').removeClass('on')
        $('.checkBox').addClass('off')
      return
    $('.checkBox').click ->
      if $(this).hasClass('off')
        $(this).removeClass('off')
        $(this).addClass('on')
      else
        $(this).removeClass('on')
        $(this).addClass('off')
      return
    $('.slide_button').click ->
      $(this).toggleClass('active')
      return
  return